跳到主要内容

图片生成 API

请求方法

POST

请求地址

打开控制台,进入 我的推理服务,找到对应的推理服务,复制下图所示位置的请求地址:

image

CURL 示例

实际使用时,请务必替换下列location变量为上图中所复制的url地址:


curl --location '{填入所启动的推理服务的地址,如上图所示,删除花括号}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {填入API Key,删除花括号}' \
--data '{
"prompt": {
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 8,
"denoise": 1,
"latent_image": ["5", 0],
"model": ["4", 0],
"negative": ["7", 0],
"positive": ["6", 0],
"sampler_name": "euler",
"scheduler": "normal",
"seed": 6578,
"steps": 20
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {"ckpt_name": "dreamshaper_8.safetensors"}
},
"5": {
"class_type": "EmptyLatentImage",
"inputs": {"batch_size": 1, "height": 512, "width": 512}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {"clip": ["4", 1], "text": "masterpiecesa2fs best 3 man"}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {"clip": ["4", 1], "text": "bad hands"}
},
"8": {
"class_type": "VAEDecode",
"inputs": {"samples": ["3", 0], "vae": ["4", 2]}
},
"9": {
"class_type": "SaveImage",
"inputs": {"filename_prefix": "ComfyUI", "images": ["8", 0]}
}
}
}'

请求 Body 参数(application/json)

参数名参数类型取值范围参数释义是否必填
promptjson符合comfyui请求参数格式要求的json文件

返回响应(json)

参数名参数类型参数释义
request_idstring返回的请求 id,根据任务 ID 请求接口获取结果